import { Api, ApiItemMethod } from "./call"
import GetConfigJSON from "./config"

async function ToAPI_IOFileApi(controller: string, method: string, type: ApiItemMethod): Promise<Api> {
    let rConfigJSON = await GetConfigJSON();
    return new Api(`${rConfigJSON.IOFileApi.BaseUrl}/api/${controller}/${method}`, type);
}

/** 输出输出文件接口 */
export class IOFileApi {
    /** 键值对数据库接口 */
    public static KeyValuePairsDb = {
        /** 获取可操作数据区域根名单 */
        async GetOperableStores() {
            return await ToAPI_IOFileApi("KeyValuePairsDb", "GetOperableStores", 'get');
        },
        /** 写入键值对数据 */
        async Write() {
            return await ToAPI_IOFileApi("KeyValuePairsDb", "Write", 'post');
        },
        /** 读取键值对数据 */
        async Read() {
            return await ToAPI_IOFileApi("KeyValuePairsDb", "Read", 'post');
        },
    }
}
